// index.js
const app = getApp();
const common = require('../../utils/common')
const md5 = require('../../utils/md5')
Page({
  data: {
    cb: true,
    topImg: common.BASE_URL + 'login_bg.png',
    loginName: '',
    password: ''
  },
  onLoad(){
    
  },
  //点击重置密码
  reset(){
    wx.navigateTo({
      url: '/pages/index/reset',
    })
  },
  changAccount(e){
    this.setData({ loginName: e.detail.value })
  },
  changPassword(e){
    this.setData({ password: e.detail.value })
  },
  login(){
    let { loginName, password } = this.data;
    if(loginName==""||password==""){
      return app.toast('账号密码不能为空')
    }
    password = md5.hex_md5(password)
    app.request({
      url: '/login/accountPasswordLogin?loginName=' + loginName + '&password=' + password,
      method: 'POST',
      success: r=>{
        app.toast('登录成功')
        wx.switchTab({
          url: '/pages/tabBar/home',
        })
      }
    })
  }
})
